package com.app.mapper;

import com.app.model.ActivityModel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 活动
 *
 * @author 16693103420
 * @since 2024-01-22
 */
@Mapper
public interface ActivityMapper extends BaseMapper<ActivityModel> {
    //查询此商家活动

    List<ActivityModel> getBusinessActivityByIdAndClassification(@Param("businessId") Integer businessId,@Param("classification") Integer classification);

    @Select("select a.* from tb_activity a where a.business_id=#{businessId}  order by a.create_time desc")
    List<ActivityModel> getBusinessActivity(@Param("businessId") Integer businessId);

    //根据甄选活动查询甄选商家ID集合
    @Select("select DISTINCT a.business_id from tb_activity a,tb_business b where a.is_pick=1 and a.business_id = b.id and b.business_status=1 and b.status=1")
    List<Integer> TranslateBusinessIdList();

    @Select("select DISTINCT a.business_id from tb_activity a,tb_business b where a.is_pick=1 and a.business_id = b.id and b.business_status=1 and b.status=1 and b.area_id=#{areaId}")
    List<Integer> businessIdList(@Param("areaId") Integer areaId);

    Integer getViewCount(@Param("id") Integer id);
}
